<template>
<view :style="showPage?'opacity: 1;':'opacity: 0;'" class="s_page_content">
		<scroll-view scroll-y="true" class="app-container" :style="'height:'+containerHeight+'px'">
			<!-- <scroll-view scroll-y="true" class="app-container" :style="'height:'+containerHeight+'px'" @scrolltolower="scrolltolower"> -->

			<view v-show="page=='index'" :class="page=='index'?'animation-fade':''">
				<cu-page-index ref="index" @changeSet="changeSet" @changeWallet="changeWallet" @openRele="openRele" ></cu-page-index>
			</view>
			<view v-show="page=='message'" :class="page=='message'?'animation-fade':''">
				<cu-page-message ref="message"></cu-page-message>
			</view>
			
			<view v-show="page=='financial'" :class="page=='financial'?'animation-fade':''">
				<cu-page-financial ref="financial"></cu-page-financial>
			</view>
			<view v-show="page=='set'" :class="page=='set'?'animation-fade':''">
				<cu-page-set ref="set" v-if="address_end!=''" :allArea="allArea" :address_end="address_end"></cu-page-set>
			</view>
		</scroll-view>
		<!-- <cu-loading></cu-loading> -->
		<view class="editBottom flex-1" style="height: calc(100rpx + env(safe-area-inset-bottom) / 2);">

		</view>


		<!-- 预加载所有tabbar 图标，以防点击的时候 闪一下 此处隐藏显示 -->
		<!-- <cover-view v-for="(item,index) in tabbar" :key="index" style="display:none;">
			<cover-image :src="item.iconPath" mode=""></cover-image>
			<cover-image :src="item.selectedIconPath" mode=""></cover-image>
		</cover-view> -->
		<view id="tabbar" class="cu-bar1 tabbar ">
			<view class="action tabbar-icon" :class="item.size=='big'?'big-icon':''" v-for="(item,index) in tabbar_list" :key="index"
			 @tap="changeTab(item)">
				<view class="flex_abc ">
					<image :class="page==item.page?'animation-scale-up':''"  v-show="page==item.page" :src="item.selectedIconPath"
					 mode="" :style="{width:index==2 ? '40upx;' : '40upx;',height:index==2 ? '40upx':'40upx;',marginBottom: index==2 ? '':''}" class="active_image"></cover-image>
					<image class="active_image" v-show="page != item.page" :src="item.iconPath" mode="" :style="{width:index==2 ? '40upx;' : '40upx',height:index==2 ? '40upx':'40upx',marginBottom: '10rpx'}"></cover-image>
				</view>
				<view :style="'color: '+(page==item.page?tabbarTextActiveColor:tabbarTextColor)+';'">
					{{item.title ||''}}
				</view>
				<view class="label" v-if="index==3 && token && isNew==1"></view>
			</view>
		</view>
		
		
		<!-- 发布动态 -->
		<view class="release" :class="openRelease?'releActive':'releActive2'">
			<view class="top"></view>
			<view class="tit">
				发布动态,
				<view class="tit2">
					让更多人了解你
					<view class="border"></view>
				</view>
			</view>
			<view class="bottomBox">
				<view class="bottom">
					<view class="imgBox" @click="toReleMsg('img')">
						<image :src="`${baseImg}/static/adminShop/upImg.png`" mode=""></image>
						图片
					</view>
					<view class="imgBox" @click="toReleMsg('video')">
						<image :src="`${baseImg}/static/adminShop/upVideo.png`" mode=""></image>
						视频
					</view>
				</view>
				<view class="iconfont" @click="openRelease=false">&#xe6a5;</view>
			</view>
		</view>
	</view>

	
</template>

<script>
	import cuPageIndex from '../components/tabBar/index/index.vue'
	import cuPageMessage from '../components/tabBar/message/message.vue'
	import cuPageFinancial from '../components/tabBar/financial/financial.vue'
	import cuPageSet from '../components/tabBar/set/set.vue'
	export default {
		components:{
			cuPageIndex,
			cuPageMessage,
			cuPageFinancial,
			cuPageSet
		},
		data() {
			return {
				page: 'index',
				showPage: false,
				containerHeight: 400,
				refreshing: true,
				themeColor: this.$store.state.tabar.themeColor,
				tabbarTextColor: this.$store.state.tabar.tabbarTextColor,
				tabbarTextActiveColor: this.$store.state.tabar.tabbarTextActiveColor,
				tabbar:this.$store.state.tabar.tabbar,
				isNew: this.$store.state.tabar.isNew,
				allArea:{
					provinceId:null,
					cityId:null,
					areaId:null,
					province:'',
					city:'',
					area:'',
					address:''
				},
				address_end:'',
				baseImg:this.$static,
				openRelease:false,
				rootRouter:[],
				tabbar_list:[],
			};
		},
		created(){
			this.getShopIndex()
			console.log(this.tabbar,'tabbar1')
			let tabbarArr = JSON.parse(JSON.stringify(this.tabbar))
			let router = this.$store.state.index.page?this.$store.state.index.page.ability:[];
			if(router.findIndex(item=>item.route == 'shopWallet')==-1 && router.findIndex(item=>item.route == 'shopSet')==-1){
				tabbarArr.splice(2,2)
			}else if(router.findIndex(item=>item.route == 'shopWallet')==-1){
				tabbarArr.splice(2,1)
			}else if(router.findIndex(item=>item.route == 'shopSet')==-1){
				tabbarArr.splice(3,1)
			}
			this.tabbar_list = tabbarArr
			// this.rootRouter = this.$store.state.index.page.page
			// console.log(this.$store.state.index.page.page,'权限路径')
		},
		onLoad(options) {
			// console.log(options,'aaaaaaaaaaaaaaaaaaaaaaa');
			// this.member_type = options.member_type
		},
		onShow(){
			
			// this.getShopIndex()
			this.getAddress()
			this.$refs.index.getIndexInfo()
			
		},
		onUnload() {
			uni.reLaunch({
				url:'/pages/mall/newIndex/newIndex'
			})
			console.log('返回返回')
			// return true
		},
		methods:{
			// 获取主页信息
			getShopIndex(){
				let sid = this.$store.state.index.sid
				let params = {
					store_id:sid
				}
				this.$api.store_storeDetail(params).then(res=>{
					console.log(res,'主页信息')
					if(res.code==1){
						this.allArea.address = res.data.address
						this.allArea.provinceId = res.data.province
						this.allArea.cityId = res.data.city
						this.allArea.areaId = res.data.area
						
						this.allArea.province = res.data.province_name
						this.allArea.city = res.data.city_name
						this.allArea.area = res.data.area_name
						this.getAddress()
					}
				})
			},
			
			// 打开发布动态
			openRele(item){
				this.openRelease = item
			},
			
			getAddress(){
				this.address_end = ''
				this.address_end = this.allArea.province+this.allArea.city+this.allArea.area+this.allArea.address
				console.log(this.address_end,'kkkk')
				console.log(this.allArea)
			},
			
			changeSet(type){
				let item = {
					page:type,
					title:'设置'
				}
				this.changeTab(item)
			},
			
			changeWallet(type){
				let item = {
					page:type,
					title:'财务'
				}
				this.changeTab(item)
			},
			
			// 跳转到发布动态
			toReleMsg(type){
				this.openRelease = false
				uni.navigateTo({
					url:'releMsg/releMsg?type='+type
				})
			},
			
			changeTab(item) {
				uni.setNavigationBarTitle({
					title: item.title
				})
				// uni.pageScrollTo({
				// 	scrollTop: 0,
				// 	duration: 0
				// });
				if (item.page == this.page) return;
				switch (item.page) {
					case 'index':
						this.page = item.page;
						this.$refs.index.getIndexInfo()
						this.$refs.index.getPriceInfo()
						break;
					case 'message':
						this.page = item.page;
						break;
					case 'publish':
						// this.showPage = false;
						// uni.navigateTo({
						// 	url: "/pages/junyao/publish/publish_index/publish_index"
						// })
						this.page = this.page;
						break;
					case 'financial':
						
						this.page = item.page;
						this.$refs.financial.getPriceInfo()
						break;
					case 'set':
						this.page = item.page;
						break;
					default:
			
				}
			
			
				// console.log(this.page)
				// uni.showToast({
				// 	title:this.page+'显示',
				// 	icon:'none'
				// })
				// 可代替onshow去做一些业务逻辑
				// 因为数据全都在vuex 动态管理
			},
			// 初始化内容区域的高度
			async init_page_size() {
				console.log("init_page_size")
				this.$nextTick(async () => {
					let sysInfo = uni.getSystemInfoSync();
					const query = uni.createSelectorQuery().in(this);
					const tabbarObj = query.select('#tabbar')
					let tabbarNodeRes = await this.syncBoundingClientRect(tabbarObj);
					let pageHeight = sysInfo.windowHeight - 50;
					this.containerHeight = pageHeight;
					this.showPage = true;
				})
			},
			syncBoundingClientRect(nodeobj) {
				return new Promise((resolve, reject) => {
					nodeobj.boundingClientRect(data => {
						console.log(data)
						resolve(data)
					}).exec();
				})
			}
		},
		mounted(){
			this.init_page_size();
		}
	}
</script>
<style>
	page{
		background-color: #F8F8F8;
	}
</style>
<style lang="less" scoped>
	@import  '../iconfont.css';
	.app-container {
		min-height: 600upx;
		background-color: #F8F8F8;
	}
	
	.tabbar-icon {
		position: relative;
	
		image {
			width: 40upx;
			height: 40upx;
			margin-bottom: 10upx;
		}
	
		.label {
			position: absolute;
			top: 0rpx;
			right: 40rpx;
			width: 16rpx;
			height: 16rpx;
			background: #de2f24;
			border-radius: 50%;
		}
	}
	
	#tabbar {
		position: fixed !important;
		bottom: 0;
		left: 0;
		width: 100%;
		overflow: visible;
		color: #333333;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		z-index: 999;
		background-color: #fff;
		// background-image: url('');
		
		// height: 200rpx;
		// border-top: 1rpx solid #e5e5e5;
		.cover_item{
			// position: relative;
			width: 164rpx;
			height: 164rpx;
			// overflow: visible;
			position: fixed;
			bottom: 0;
			left: 294rpx;
			z-index: 99;
			.active_image{
				// margin-top: -80rpx;
				
				// z-index: 55;
				// overflow: visible;
			}
		}
	
	}
	
	// 发布动态
		.release{
			width: 100%;
			height: 100%;
			position: fixed !important;
			top: -100%;
			left: 0;
			z-index: 99999;
			display: flex;
			transition: 0.5s;
			flex-direction: column;
			justify-content: space-between;
			background-color: rgba(255,255,255,1);
			.top{
				width: 100%;
				height: 100%;
				position: absolute;
				top: 0;
				z-index: -1;
				left: 0;
				background: linear-gradient(180deg, #ccc 0%, #fff 100%);
			}
			.tit{
				font: 500 46rpx/76rpx PingFang SC;
				color: #0A0605;
				margin-top: 272rpx;
				padding-left: 60rpx;
				.tit2{
					position: relative;
					.border{
						width: 184rpx;
						height: 10rpx;
						background-color: #EBB964;
						position: absolute;
						left: 0;
						bottom: 20rpx;
						z-index: -1;
					}
				}
			}
			.bottomBox{
				margin-bottom: 138rpx;
				.bottom{
					display: flex;
					justify-content: space-around;
					align-items: center;
					.imgBox{
						display: flex;
						flex-direction: column;
						align-items: center;
						image{
							width: 168rpx;
							height: 136rpx;
						}
						font: 500 26rpx/20rpx PingFang SC;
						color: #0A0605;
					}
				}
				.iconfont{
					margin-top: 140rpx;
					font-size: 50rpx;
					text-align: center;
					
				}
			}
		}
		.releActive{
			top:0rpx;
		}
		
	.tabbar-icon.big-icon {
		position: relative;
		bottom: 20upx;
	
		image {
			width: 40upx;
			height: 40upx;
		}
	}
	
	.flex_abc {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.container{
		position: relative;
		width: 750rpx;
		background: #F8F8F8;
		opacity: 1;
		.icon-fenxiang{
			width: 34rpx;
			position: relative;
			color: #fff;
			top: -62rpx;
			left: 28rpx;
		}
		.title{
			width: 750rpx;
			height: 538rpx;
			background: url(https://manager.ryz1620.com/static/home-personal/personal-bg.png);
			border-radius: 0 0 2em 2em;
			background-size: 100% 100%;
			color: #fff;
			padding: 124rpx 66rpx 146rpx 24rpx;
			.title-top{
				display: flex;
				width: 100%;
				height: 112rpx;
				image{
					width: 112rpx;
					height: 112rpx;
					background: rgba(0, 0, 0, 0);
					box-shadow: 0rpx 0rpx 20rpx rgba(0, 0, 0, 0.1);
					border-radius: 50%;
					opacity: 1;
					margin-right: 36rpx;
				}
				.name{
					.text{
						margin-bottom: 16rpx;
						font-size: 40rpx;
						font-family: PingFang SC;
						font-weight: 600;
						color: #FFFFFF;
						opacity: 1;
					}
					.redact{
						width: 116rpx;
						height: 48rpx;
						background: rgba(255,255,255,0.1);
						border-radius: 24rpx;
						// align-items: center;
						text-align: center;
						line-height: 48rpx;
						.txt{
							// width: 52rpx;
							height: 40rpx;
							font-size: 26rpx;
							font-family: PingFang SC;
							font-weight: 400;
							
							text-align: center;
							color: #FFFFFF;
							opacity: 1;
						}
					}
				}
			}
			.title-content{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 76rpx 60rpx 146rpx 36rpx;
				view{
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					&:first-child{
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: 500;
						line-height: 32rpx;
						color: #FFFFFF;
					}
					text{
						&:last-child{
							font-size: 22rpx;
							font-family: PingFang SC;
							font-weight: 400;
							line-height: 22rpx;
							color: #A0A0A0;
							margin-top: 18rpx;
						}
					}
				}
			}
		}
		.content{
			position: absolute;
			top: 436rpx;
			padding: 0 24rpx 156rpx 24rpx;			
			.menu{
				width: 702rpx;
				// height: 364rpx;
				padding: 36rpx 66rpx 0rpx 64rpx;
				background: #FEFFFE;
				opacity: 1;
				border-radius: 16rpx;
				display: flex;
				flex-wrap: wrap;
				// justify-content: space-between;					
				
				margin-bottom: 16rpx;				
				.menu-list{
					font-size: 24rpx;
					margin-right: 132rpx;
					margin-bottom: 40rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					
					&:nth-child(3) {
						margin-right:0
					} 
					&:nth-child(6) {
						margin-right:0
					} 
					image{
						width: 80rpx;
						height: 84rpx;
					}
				}
			}
			.sub-title{
				display: flex;
				justify-content: space-between;
				text{
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: 600;
					line-height: 32rpx;
					color: #0A0605;
				}
				image{
					width: 52rpx;
					height: 52rpx;
				}
			}
			.data-sheet{
				
				height: 486rpx;
				background: #FFFFFF;
				opacity: 1;
				border-radius: 16rpx;
				margin-bottom: 16rpx;
			}
			.common{
				width: 702rpx;
				height: 616rpx;
				background: #FFFFFF;
				opacity: 1;
				border-radius: 16rpx;
				margin-bottom: 16rpx;
				padding: 32rpx 24rpx 28rpx 28rpx;
				
				.common-content{
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 28rpx 0;
					border-bottom: 2rpx solid #F5F5F5;
					.common-left{
						image{
							width: 76rpx;
							height: 76rpx;
							margin-right: 24rpx;
						}
						display: flex;
						.left-content{
							display: flex;
							flex-direction: column;
							text{
								&:nth-child(1){
									font-size: 26rpx;
									font-family: PingFang SC;
									font-weight: 500;
									line-height: 40rpx;
									color: #DBA954;
								}
								&:nth-child(2){
									font-size: 26rpx;
									font-family: PingFang SC;
									font-weight: 400;
									line-height: 40rpx;
									color: #505050;
								}
								&:nth-child(3){
									font-size: 22rpx;
									font-family: PingFang SC;
									font-weight: 400;
									line-height: 40rpx;
									color: #A0A0A0;
								}
							}
						}
					}
					image{
						width: 116rpx;
						height: 116rpx;
					}
					&:last-child{
						border-bottom:0
					}
				}
			}
			.information{
				width: 702rpx;
				
				background: #FFFFFF;
				opacity: 1;
				border-radius: 16rpx;
				padding: 32rpx 24rpx 28rpx 28rpx;
				.list{
					display: flex;
					justify-content: space-between;
					border-bottom: 1rpx solid #F5F5F5;
					padding: 24rpx 0;
					&:last-child{
						border-bottom:0
					}
					.list-left{
						
						.des {
							width: 356rpx;
							height:128rpx;
							font-size: 28rpx;
							font-family: PingFang SC;
							font-weight: 400;
							line-height:44rpx;
							color: #0A0605;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 3;
							overflow: hidden;
						}
						.time {
							padding-top: 28rpx;
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: 300;
							line-height: 24rpx;
						}
					}
					.info-img{
						width: 250rpx;
						height: 190rpx;
						border-radius: 8rpx;
					}
				}
			}
		}
	}
</style>